package WebServices;

import java.lang.*;
import java.io.*;
import java.net.*;

public class CallAlex {

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		String sMessage; 
		sMessage = "POST /ksnet2/HospitalService/server.php HTTP/1.0\r\nHost: 195.201.73.101\r\nContent-Type: text/xml\r\nContent-Length: 400\r\nSOAPAction: 'urn:xmethods-delayed-quotes#getHospitals'\r\n\r\n<?xml version='1.0'?>\r\n<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='http://195.201.73.101/kanet2/HospitalService/server.wsdl' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><SOAP-ENV:Body><getHospitals/></SOAP-ENV:Body></SOAP-ENV:Envelope>\r\n\r\n";
		sMessage = "POST http://195.201.73.101/ksnet2/HospitalService/server.php HTTP/1.0\r\nContent-Type: text/xml\r\nContent-Length: 400\r\nSOAPAction: 'urn:xmethods-delayed-quotes#getHospitals'\r\n\r\n<?xml version='1.0'?>\r\n<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='http://195.201.73.101/kanet2/HospitalService/server.wsdl' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><SOAP-ENV:Body><getHospitals/></SOAP-ENV:Body></SOAP-ENV:Envelope>\r\n\r\n";
		//	String sMessage = "POST /scripts/soap/test.php HTTP/1.0 Content-Type: text/xml Content-Length: 500 SOAPAction: 'urn:xmethods-delayed-quotes#getHospitals <?xml version='1.0'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='http://195.201.73.101/kanet2/HospitalService/server.wsdl' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>    <SOAP-ENV:Body>       <getHospitals/>    </SOAP-ENV:Body> </SOAP-ENV:Envelope>\n";
		String sResult;
		try
		{
			//	Socket sktAux = new Socket( "195.201.73.101", 80 );	//	195.201.73.101
			Socket sktAux = new Socket( "195.201.73.126", 110 );	//	195.201.73.101
			
			System.out.println( "Socket - begin" );
			/*
			PrintWriter outParam = new PrintWriter( sktAux.getOutputStream(), true );
			
			System.out.println( "Socket writer - created" );
			
			outParam.println( sMessage );
			
			System.out.println( "Socket writer - end" );
			*/
			BufferedReader inResult = new BufferedReader
			(
					new InputStreamReader( sktAux.getInputStream() )
			);
			
			System.out.println( "Socket reader - created" );
			
			long lStartTime = System.currentTimeMillis();
			boolean bCont = true;
	
			while ( !inResult.ready() && bCont ) 
			{ 
				if ( ( System.currentTimeMillis() - lStartTime  ) > 10000 ) bCont = false; 
			};
			
			if ( bCont )
			{
				while ( ( sResult = inResult.readLine() ) != null ) System.out.println( sResult );
			
				System.out.println( "Socket reader - end" );
			}
			else System.out.println( "Timeout error" );
			inResult.close();
			sktAux.close();
	
		}
		catch ( Exception e )
		{
			System.out.println( "Error!" );
		}

	}

}
